package org.example.myleet.rosalind.conv;

import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Solution {
    public static void main(String[] args) throws IOException {
        Solution solution = new Solution();
        String path = solution.getClass().getResource("").getPath() + "example.txt";
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
        List<BigDecimal> S1 = new ArrayList<>();
        List<BigDecimal> S2 = new ArrayList<>();
        String line = br.readLine();
        String[] numbers = line.trim().split(" ");
        for (String number : numbers) {
            S1.add(new BigDecimal(number));
        }
        line = br.readLine();
        numbers = line.trim().split(" ");
        for (String number : numbers) {
            S2.add(new BigDecimal(number));
        }
        int maxCount = 0;
        String diffCandidate = "";
        Map<String, Integer> diffMapCount = new HashMap<>();
        for (BigDecimal s1 : S1) {
            for (BigDecimal s2 : S2) {
                String diff = s1.subtract(s2).setScale(5, RoundingMode.HALF_UP).toPlainString();
                int count = diffMapCount.getOrDefault(diff, 0) + 1;
                if (count > maxCount) {
                    maxCount = count;
                    diffCandidate = diff;
                }
                diffMapCount.put(diff, count);
            }
        }
        System.out.println(maxCount);
        System.out.println(diffCandidate);
        br.close();
    }
}
